package com.creative.accountsdk.net.account;

import com.creative.accountsdk.UserData;
import com.creative.accountsdk.net.Protocol;
import com.creative.accountsdk.net.XParams;
import com.loopj.android.http.RequestParams;

import org.json.JSONObject;

/**
 * Created by wang_qian on 2015/11/27.
 */
public class CheckTeacherInviteCodeProtocol extends Protocol {

    private UserData userData;
    private String  inviteCode;
    public  String  schoolName;
    private  JSONObject  jsonSchool;

    public CheckTeacherInviteCodeProtocol(String invitecode) {
        inviteCode = invitecode;
        userData = UserData.getInstance();
    }

    @Override
    public RequestParams getParams() {
        long  uid = userData.getUid();


        return new XParams().put("uid", uid).put("ticode", inviteCode).getParams();
    }

    @Override
    public String getUrl() {
        return getUrlPrefix()+"sch/info";
    }

    @Override
    protected void parseReturnMap(JSONObject returnMap) {

        jsonSchool = returnMap.optJSONObject("school");
        if (jsonSchool != null && jsonSchool.has("name")) {
            schoolName = jsonSchool.optString("name");
        }

    }
}
